const demo = require(process.argv[2])
console.log('running', demo)

console.log('1 callback')
demo.sleep_and_calc(1, (suc, val)=>console.log('result:', suc, val))

console.log('2 callback')
demo.sleep_and_calc(2, (suc, val)=>console.log('result:', suc, val))

console.log('10 callback')
demo.sleep_and_calc(10, (suc, val)=>console.log('result:', suc, val))

console.log('7 callback')
demo.sleep_and_calc(7, (suc, val)=>console.log('result:', suc, val))

console.log('1 promise')
demo.sleep_and_calc(1).then(val=>console.log('then:', val)).catch(val=>console.log('catch:', val))

console.log('2 promise')
demo.sleep_and_calc(2).then(val=>console.log('then:', val)).catch(val=>console.log('catch:', val))

console.log('10 promise')
demo.sleep_and_calc(10).then(val=>console.log('then:', val)).catch(val=>console.log('catch:', val))

console.log('7 promise')
demo.sleep_and_calc(7).then(val=>console.log('then:', val)).catch(val=>console.log('catch:', val))

console.log('waiting')

/*
running { sleep_and_calc: [Function: sleep_and_calc] }
1 callback
2 callback
10 callback
7 callback
D 2546113:2546120 AsyncExec +32 sleep
D 2546113:2546123 AsyncExec +32 sleep
1 promise
D 2546113:2546121 AsyncExec +32 sleep
2 promise
D 2546113:2546122 AsyncExec +32 sleep
10 promise
7 promise
waiting
D 2546113:2546121 AsyncExec +32 sleep
D 2546113:2546123 AsyncExec +32 sleep
result: true [Number: 2]
result: true [Number: 0]
D 2546113:2546120 AsyncExec +32 sleep
result: false [Number: 4]
D 2546113:2546122 AsyncExec +32 sleep
result: false [Number: 2]
then: [Number: 0]
then: [Number: 2]
catch: [Number: 4]
catch: [Number: 2]
*/
